home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / hsclib / posteval.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  3.5 KB  |  118 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1995-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. /*
  21.  * hsclib/posteval.c
  22.  *
  23.  * functions to postprocess attributes
  24.  * (remember IDs, references, etc)
  25.  *
  26.  * updated:  6-Sep-1995
  27.  * created:  7-Jul-1995
  28.  */
  29.  
  30. #define NOEXTERN_HSCLIB_EVAL_H
  31.  
  32. #include <ctype.h>
  33.  
  34. #include "hsclib/inc_base.h"
  35.  
  36. #include "hscprj/document.h"
  37. #include "hsclib/idref.h"
  38. #include "hsclib/uri.h"
  39.  
  40. /*
  41.  * postprocess_attributes
  42.  *
  43.  * This functions scans a tag's list of attributes for an URI-attributes
  44.  * refering to an external URI. If it succeeds, and the hsc-process
  45.  * has it's hp->strip_ext flag enabled, the function exits.
  46.  *
  47.  * Otherwise, it scans the attributes for new IDs and references
  48.  * and updates the document-data if neccessary (but only for start-tags)
  49.  *
  50.  * params:
  51.  *   hp ....... hsc-process
  52.  *   tag ... tag whichs attribute list chould be examined
  53.  *   open_tag .. for end-tags, the document-data should not be
  54.  *               updated again
  55.  * result:
  56.  *   TRUE, if tag should NOT be stripped
  57.  */
  58. BOOL postprocess_tagattr(HSCPRC * hp, HSCTAG * tag, BOOL open_tag)
  59. {
  60.     BOOL dontstrip = TRUE;
  61.  
  62.     if (tag->attr)
  63.     {
  64.  
  65.         /*
  66.          * find out, if list should be refused
  67.          */
  68.         if (hp->strip_ext
  69.             && tag->uri_stripext
  70.             && get_vartext(tag->uri_stripext)
  71.             && (uri_kind(get_vartext(tag->uri_stripext)) == URI_ext)
  72.             )
  73.         {
  74.             D(fprintf(stderr, DHL "strip external\n"));
  75.             dontstrip = FALSE;
  76.         }
  77.         else if (open_tag)
  78.         {
  79.             /*
  80.              * search for new IDs and references
  81.              */
  82.             DLNODE *nd = dll_first(tag->attr);
  83.             while (nd)
  84.             {
  85.                 HSCATTR *attrib = (HSCATTR *) dln_data(nd);
  86.                 STRPTR value = get_vartext(attrib);
  87.  
  88.                 if (value)
  89.                 {
  90.                     if (attrib->vartype == VT_URI)
  91.                     {
  92.                         /* new reference */
  93.                         INFILEPOS *fpos = new_infilepos(hp->inpf);
  94.                         CALLER *newcaller = fpos2caller(fpos);
  95.                         HSCREF *newref =
  96.                         app_reference(hp->project->document, value);
  97.  
  98.                         newref->caller = newcaller;
  99.  
  100.                         del_infilepos(fpos);
  101.                         D(fprintf(stderr, DHL "new REFERENCE: `%s'\n", value));
  102.  
  103.                     }
  104.                     else if (attrib->vartype == VT_ID)
  105.                     {
  106.                         /* new id defined */
  107.                         D(fprintf(stderr, DHL "new ID: `%s'\n", value));
  108.                         add_local_iddef(hp, value);
  109.                     }
  110.                 }
  111.                 nd = dln_next(nd);
  112.             }
  113.         }
  114.     }
  115.     return (dontstrip);
  116. }
  117.  
  118.